package com.matchmealpha;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.BaseAdapter;

public class AlertListAdapter extends BaseAdapter   {
	private Context context;
	private List<Alert> alertList;
	private int selectedPosition;
	private int callerID;
	String sessionid;
	
	public AlertListAdapter(Context context, List<Alert> alertList, int callerID, String sessionid) {
		this.context = context;
		this.alertList = alertList;
		this.selectedPosition = Adapter.NO_SELECTION;
		this.callerID = callerID;
		this.sessionid = sessionid;
	}
	
	public int getSelectedPosition(){
		return this.selectedPosition;
	}
	
	@Override
	public int getCount() {
		return this.alertList.size();
	}

	@Override
	public Object getItem(int position) {
		return this.alertList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return  this.alertList.get(position).getAlertID();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if ( convertView != null ){
			((AlertView)convertView).setAlertItem(this.alertList.get(position));
		}
		else {
			convertView = new AlertView(context,alertList.get(position),this.callerID, sessionid);
		}
			
		return convertView;
	}


}
